package org.timeticker;

import java.util.Date;

/**
 * Day range
 *
 * @author Ivan Latysh
 * @version 0.1
 * @since 25-Aug-2007 : 4:36:53 PM
 */
public class DayRange {

  private Day from;

  private Day to;

  public DayRange() {
  }

  public DayRange(Day from, Day to) {
    this.from = from;
    this.to = to;
  }

  public DayRange(Date from, Date to) {
    this.from = new Day(from.getTime());
    this.to = new Day(to.getTime());
  }

  public Day getFrom() {
    return from;
  }

  public void setFrom(Day from) {
    this.from = from;
  }

  public Day getTo() {
    return to;
  }

  public void setTo(Day to) {
    this.to = to;
  }

  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("[").append(from).append(" - ").append(to).append("]");
    return sb.toString();
  }

  /**
   * Return <tt>true</tt> only when given date range represent the same date range as this date range.
   *
   * @param obj date range to compare to
   * @return <tt>true</tt> id both ranges are the same, <tt>false</tt> otherwise
   */
  public boolean equals(Object obj) {
    if (null==obj || !(obj instanceof DayRange)) return false;    
    return ((DayRange)obj).getFrom().equals(from) && ((DayRange)obj).getTo().equals(to);
  }
}
